home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / contrib / pdcurs22 / src / portable / insch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-26  |  6.2 KB  |  169 lines

  1. /*
  2. ***************************************************************************
  3. * This file comprises part of PDCurses. PDCurses is Public Domain software.
  4. * You may use this code for whatever purposes you desire. This software
  5. * is provided AS IS with NO WARRANTY whatsoever.
  6. * Should this software be used in another application, an acknowledgement
  7. * that PDCurses code is used would be appreciated, but is not mandatory.
  8. *
  9. * Any changes which you make to this software which may improve or enhance
  10. * it, should be forwarded to the current maintainer for the benefit of 
  11. * other users.
  12. *
  13. * The only restriction placed on this code is that no distribution of
  14. * modified PDCurses code be made under the PDCurses name, by anyone
  15. * other than the current maintainer.
  16. * See the file maintain.er for details of the current maintainer.
  17. ***************************************************************************
  18. */
  19. #define    CURSES_LIBRARY    1
  20. #include <curses.h>
  21.  
  22. /* undefine any macros for functions defined in this module */
  23. #undef    insch
  24. #undef    winsch
  25. #undef    mvinsch
  26. #undef    mvwinsch
  27.  
  28. /* undefine any macros for functions called by this module if in debug mode */
  29. #ifdef PDCDEBUG
  30. #  undef    refresh
  31. #  undef    wrefresh
  32. #  undef    move
  33. #  undef    wmove
  34. #endif
  35.  
  36. #ifdef PDCDEBUG
  37. char *rcsid_insch  = "$Id$";
  38. #endif
  39.  
  40. /*man-start*********************************************************************
  41.  
  42.   Name:                                                         insch
  43.  
  44.   Synopsis:
  45.       int insch(chtype ch);
  46.       int winsch(WINDOW *win, chtype ch);
  47.       int mvinsch(int y, int x, chtype ch);
  48.       int mvwinsch(WINDOW *win, int y, int x, chtype ch);
  49.  
  50.   X/Open Description:
  51.      The routine insch() inserts the character ch into the default
  52.      window at the current cursor position and the window cursor is
  53.      advanced.  The character is of the type chtype as containing
  54.      both data and attributes.
  55.  
  56.      The routine winsch() inserts the character ch into the specified
  57.      window at the current cursor position.  The cursor position is
  58.      advanced.
  59.  
  60.      The routine mvinsch() moves the cursor to the specified (y, x)
  61.      position and inserts the character ch into the default window.
  62.      The cursor position is advanced after the character has been
  63.      inserted.
  64.  
  65.      The routine mvwinsch() moves the cursor to the specified (y, x)
  66.      position and inserts the character ch into the specified
  67.      window.  The cursor position is advanced after the character
  68.      has been inserted.
  69.  
  70.      The routine echochar() inserts the character ch into stdscr
  71.      at the current cursor position and a refresh() is called.  
  72.      The cursor position is advanced.
  73.  
  74.      The routine wechochar() inserts the character ch into the
  75.      specified window at the current cursor position and a wrefresh() 
  76.      is called. The cursor position is advanced.
  77.  
  78.      All these routines are similar to putchar().  The following
  79.      information applies to all the routines.
  80.  
  81.      If the cursor moves on to the right margin, an automatic
  82.      newline is performed.  If scrollok is enabled, and a character
  83.      is added to the bottom right corner of the screen, the
  84.      scrolling region will be scrolled up one line.  If scrolling
  85.      is not allowed, ERR will be returned.
  86.  
  87.      If ch is a tab, newline, or backspace, the cursor will be
  88.      moved appropriately within the window.  If ch is a newline,
  89.      the clrtoeol routine is called before the cursor is moved to
  90.      the beginning of the next line.  If newline mapping is off,
  91.      the cursor will be moved to the next line, but the x
  92.      coordinate will be unchanged.  If ch is a tab the cursor is
  93.      moved to the next tab position within the window.  If ch is
  94.      another control character, it will be drawn in the ^X
  95.      notation.  Calling the inch() routine after adding a control
  96.      character returns the representation of the control character,
  97.      not the control character.
  98.  
  99.      Video attributes can be combined with a character by ORing
  100.      them into the parameter.  This will result in these attributes
  101.      being set.  The intent here is that text, including
  102.      attributes, can be copied from one place to another using inch()
  103.      and insch().
  104.  
  105.      NOTE: All these functions are implemented as macros.
  106.  
  107.   PDCurses Description:
  108.      Depending upon the state of the raw character output, 7- or
  109.      8-bit characters will be output.
  110.  
  111.   X/Open Return Value:
  112.      All functions return OK on success and ERR on error.
  113.  
  114.   X/Open Errors:
  115.      No errors are defined for this function.
  116.  
  117.   Portability                             X/Open    BSD    SYS V
  118.                                           Dec '88
  119.       insch                                 Y        Y       Y
  120.       winsch                                Y        Y       Y
  121.       mvinsch                               Y        Y       Y
  122.       mvwinsch                              Y        Y       Y
  123.  
  124. **man-end**********************************************************************/
  125.  
  126. /***********************************************************************/
  127. int    insch(chtype ch)
  128. /***********************************************************************/
  129. {
  130. #ifdef PDCDEBUG
  131.     if (trace_on) PDC_debug("insch() - called\n");
  132. #endif
  133.  
  134.     return( PDC_chins( stdscr, ch, (bool)(!(_cursvar.raw_out))) );
  135. }
  136. /***********************************************************************/
  137. int    winsch(WINDOW *win, chtype ch)
  138. /***********************************************************************/
  139. {
  140. #ifdef PDCDEBUG
  141.     if (trace_on) PDC_debug("winsch() - called\n");
  142. #endif
  143.  
  144.     return( PDC_chins( win, ch, (bool)(!(_cursvar.raw_out))) );
  145. }
  146. /***********************************************************************/
  147. int    mvinsch(int y, int x, chtype ch)
  148. /***********************************************************************/
  149. {
  150. #ifdef PDCDEBUG
  151.     if (trace_on) PDC_debug("mvinsch() - called\n");
  152. #endif
  153.     if (move(y,x) == ERR)
  154.         return(ERR);
  155.     return( PDC_chins( stdscr, ch, (bool)(!(_cursvar.raw_out))) );
  156. }
  157. /***********************************************************************/
  158. int    mvwinsch(WINDOW *win, int y, int x, chtype ch)
  159. /***********************************************************************/
  160. {
  161. #ifdef PDCDEBUG
  162.     if (trace_on) PDC_debug("mvwinsch() - called\n");
  163. #endif
  164.     if (wmove(win,y,x) == ERR)
  165.         return(ERR);
  166.     return( PDC_chins( win, ch, (bool)(!(_cursvar.raw_out))) );
  167. }
  168.